# -*- coding: utf-8 -*-

import time
import sys
import math
import random
import datetime
from py_stealth import *

from kanchai import *
c=cc()
#c.fw = [2612, 638, 2740, 783]
c.fw = [2615, 654, 2735, 789]
c.bs = 0x0F43
c.inj = 'can\'t|enough|not'
c.xz = 0x4004C11B
c.homex = 2510
c.homey = 560
c.homexy = 0x40CE6CB4
c.dian = 0x40CE6CCF

print(c.fw)
print(c.bs)
print(c.inj)
print(c.xz)
print(c.homex)
print(c.homey)
print(c.homexy) 
print(c.dian)

while 1:
    for x in range(c.fw[0], c.fw[2]):
        for y in range(c.fw[1], c.fw[3]):
            #print  str(x) + ':' + str(y)
            Tile = ReadStaticsXY(x, y, WorldNum())
            if len(Tile) > 0 and Tile[0]['Tile'] in range(3274, 3497):
                sTile = Tile[0]['Tile']
                sX = Tile[0]['X']
                sY = Tile[0]['Y']
                sZ = Tile[0]['Z']
                #print Tile
                f = open('c:\\a.txt', 'a+')
                f.write(str(Tile[0]) + '\n')
                f.close
                NewMoveXY(sX, sY, False, 1, True)
                c.kc(sTile, sX, sY, sZ)
        for y in range(c.fw[3], c.fw[1], -1):
            #print str(x) + ':' + str(y)
            Tile = ReadStaticsXY(x, y, WorldNum())
            if len(Tile) > 0 and Tile[0]['Tile'] in range(3274, 3497):
                sTile = Tile[0]['Tile']
                sX = Tile[0]['X']
                sY = Tile[0]['Y']
                sZ = Tile[0]['Z']
                #print Tile
                f = open('c:\\a.txt', 'a+')
                f.write(str(Tile[0]) + '\n')
                f.close
                NewMoveXY(sX, sY, False, 1, True)
                c.kc(sTile, sX, sY, sZ)
